﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CCWin;

namespace MyQQ
{
    partial class ChatForm : CCWin.CCSkinMain
    {
        private string toWho;
        private string name;
        public ChatForm(string name,string toWho)
        {
            InitializeComponent();
            this.name = name;
            this.toWho = toWho;
            Net.NetReciver.Listener.MessageArrived += this.GetInfo;
        }

        public void GetInfo(Message.Message msg)
        {
            if (msg.Type == Message.MessageType.Message)
            {
                if (msg.Towho.Name == name && msg.FromWho.Name == toWho)
                {
                    this.rtfRichTextBox1.Text += toWho + "：" + msg.ChatInfo + @"
";
                }
            }
        }

        private void skinButtom1_Click(object sender, EventArgs e)
        {
            Message.Message msg = new Message.Message();
            msg.Towho = new Message.ToWhoMessage(toWho);
            msg.FromWho = new Message.FromWhoMessage(name);
            msg.ChatInfo = rtfRichTextBox2.Text;
            rtfRichTextBox2.Text = string.Empty;
            Net.NetSender.Sender.SendMessage(msg);
        }
    }
}
